package com.scgaopan.disruptor.pakingdemo.handler;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
import com.scgaopan.disruptor.pakingdemo.DateUtil;
import com.scgaopan.disruptor.pakingdemo.MyInParkingDataEvent;

/**
 * Author:scgaopan
 * Date:18/10/25
 * Description:第一个消费者，负责保存进场汽车的信息
 */
public class MyParkingDataInDbHandler implements EventHandler<MyInParkingDataEvent>, WorkHandler<MyInParkingDataEvent> {


    public void onEvent(MyInParkingDataEvent event, long sequence, boolean endOfBatch) throws Exception {
        System.out.println("this is Eventhandler executed.........data="+event.getCarLicense());
       this.onEvent(event);

    }

    public void onEvent(MyInParkingDataEvent event) throws Exception {

        System.out.println("this is WorkHandler executed.........data="+event.getCarLicense());
        Thread.sleep(3000);
        System.out.println(DateUtil.getCurrentTime()+"  成功保存车牌信息到database中，currentThread="+Thread.currentThread().getId()+",data="+event.getCarLicense());



    }
}
